#include <roaring/roaring.h>
#include <string>
#include <map>
#include "ScalarStorage.h"
#include "logger.h"
#include <sstream>
#include <iostream>
class FilterIndex{
public:
    enum class Operation{
        EQUAL,
        NOT_EQUAL
    };
    FilterIndex();
    //写入
    void addIntFieldFilter(const std::string& fieldName, int64_t value, uint64_t id);
    //更新
    void updateIntFieldFilter(const std::string& fieldName, int64_t* old_value,int64_t new_value, uint64_t id);
    //查询
    void getIntFieldFilter(const std::string& fieldName, int64_t value, Operation op, roaring_bitmap_t* result_bitmap);

    //持久化相关
    //序列化
    std::string serializeIntFieldFilter() const;
    //反序列化
    void deserializeIntFieldFilter(const std::string& serialized_data);
    //保存
    void saveIndex(ScalarStorage& scalarStorage,const std::string&key);
    //加载
    void loadIndex(ScalarStorage& scalarStorage,const std::string&key);

private:
    std::map<std::string, std::map<int64_t, roaring_bitmap_t*>> intFieldFilter;
};